<template>
	<view>
		<u-sticky bgColor="#6492FF" offsetTop=0 customNavHeight=0>
			<navbox title="编辑提现账号"></navbox>
		</u-sticky>
		<view class="con">
			<view class="con__box">
				<view class="con__box__item">
					<view class="con__box__title">
						开户行
					</view>
					<input placeholder="请输入开户行" placeholder-style="font-size:26rpx;" v-model='form.bank' type="text" class="con__box__inpbox" />
				</view>
				<view class="con__box__item">
					<view class="con__box__title">
						银行卡号
					</view>
					<input placeholder="请输入银行卡号" placeholder-style="font-size:26rpx;" v-model="form.account" type="number" class="con__box__inpbox" />
				</view>
				<view class="con__box__footer">
					<u-button :loading="loading" text="确认" @click="submit" color="#6492FF" shape='circle'></u-button>
				</view>
				
			</view>
		</view>
	</view>
</template>

<script>
	import {txAccount,queryAccount} from '@/api/user.js'
	export default {
		data() {
			return {
				form:{
					account:'',
					bank:'',
					id:''
					// customerId:uni.getStorageSync('ytbuser').id
				},
				text:'新增成功',
				loading:false
			};
		},
		methods:{
			submit(){
				this.loading=true
				// console.log(this.form)
				txAccount(this.form).then(res=>{
					if(res.data.code==200){
						this.$u.toast(this.text)
						setTimeout(()=>{
							this.loading=false
							uni.navigateBack()
						},2000)
					}
				})
			}
		},
		onLoad(option) {
			this.form.id=option.accountid
			queryAccount().then(res=>{
				if(res.data.code==200){
					this.accountBalance=res.data.data.customer.accountBalance
					if(res.data.data.accounts.length>0){
						this.text='账户已修改'
						this.form={
							account:res.data.data.accounts[0].account,
							bank:res.data.data.accounts[0].bank,
							id:res.data.data.accounts[0].id
						}
					}else{
						this.form={}
					}
				}
			})
		}
	}
</script>

<style lang="scss">
page{
	background-color: #f6f6f6;
}
.con{
	padding: 25rpx 16rpx;
	&__box{
		padding: 0 40rpx;
		background: #FFFFFF;
		border-radius: 14rpx;
		margin-bottom: 25rpx;
		&__item{
			padding: 34rpx 0 21rpx;
			border-bottom: 1rpx solid rgba(205, 205, 205, .5);
		}
		&__title{
			font-family: Source Han Sans SC;
			font-weight: 400;
			font-size: 34rpx;
			color: #3E3D3D;
			line-height: 34rpx;
			
		}
		&__inpbox{
			font-family: Source Han Sans SC;
			font-weight: 400;
			font-size: 26rpx;
			color: #707070;
			line-height: 26rpx;
			margin-top: 36rpx;
			
		}
		&__footer{
			padding: 36rpx 56rpx;
		}
	}	
}
</style>
